#!/bin/bash
abpwd=`pwd`
echo $abpwd    #py file
echo $0
#$0 shell name
#$1 git name
#$2 git path
#$3 mcu path
#
cd ./database
pwd
mkdir $abpwd/temp/"$1"
echo "START">$abpwd/temp/"$1"/.mesg

git clone --progress $2 >$abpwd/temp/"$1"/"$1".txt 2>&1

#clone success?
end_str=`tail -n 1 $abpwd/temp/"$1"/"$1".txt`
#if [ $end_str=="finish clone\n" ]
#then echo finish---------------------->
#fi

echo $end_str

echo "finish clone">>$abpwd/temp/"$1"/"$1".txt


wget -P $abpwd/database/$1/mcu/ $3 >> $abpwd/temp/"$1"/"$1".txt 2>&1

filename=`echo $3|sed -r 's:.*/([^\/].*):\1:g'`
echo $filename
#get success?
if [ ! -f "$abpwd/database/$1/mcu/$filename" ];
then 
    echo "mcu file download fail"
fi

echo "END">$abpwd/temp/"$1"/.mesg



